<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="org.json.*"%>
<%@ page import="com.gzgi.framework.*"%>
<%@ page import="com.gzgi.framework.util.*"%>
<%@ page import="com.gzgi.framework.context.*"%>
<%@ page import="com.gzgi.framework.config.*"%>
<%@ page import="com.gzgi.framework.integration.*"%>
<%@ page import="com.gzgi.framework.sys.model.*"%>
<%@ page import="com.gzgi.framework.tree.*"%>
<%@ page import="com.gzgi.framework.tree.helper.*"%>
<%
     String node = request.getParameter("node");
	 TreeModelHelper helper = new TreeModelHelper();
     Map paramMap = RequestUtil.getParameterMap(request);
	 //System.out.println(paramMap);
     if(node != null ){
		 paramMap.put("node", node);
		 paramMap.put("parentId", node);
		 if("0".equals(node)){
			 paramMap.remove("node");
		 } else {
			 paramMap.remove("code");
		 }
		 List treeModels = IntegrationFactory.getTreeModels(paramMap);
		 JSONArray array = new JSONArray();
		 if(treeModels != null && treeModels.size() > 0){
			 for (int i = 0; i < treeModels.size(); i++) {
				TreeModel treeModel = (TreeModel) treeModels.get(i);
				JSONObject row = new JSONObject();
				row.put("id", treeModel.getId());
				row.put("text", treeModel.getName());
				row.put("leaf", new Boolean(false));
				row.put("checked",  new Boolean(false));
				array.put(row);
			 }
		 } 
	     out.println(array);
	 }
%>